package com.itheima.service;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.dao.SprotsDao;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.pojo.Reos;
import com.itheima.pojo.Sprots;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 运动库管理
 */
@Service(interfaceClass = SprotsService.class)
@Transactional
public class SprotsServiceImpl implements SprotsService {

    @Autowired
    private SprotsDao sprotsDao;

    @Override
    public void add(List<Sprots> sprotsArrayList) {
        if (sprotsArrayList !=null && sprotsArrayList.size()>0){
            for (Sprots sprots : sprotsArrayList) {
                sprotsDao.add(sprots);
            }
        }
    }
//分页查询
    @Override
    public PageResult findpageRepos(QueryPageBean queryPageBean) {
        //当前页
        Integer currentPage = queryPageBean.getCurrentPage();
        //每页显示条数
        Integer pageSize = queryPageBean.getPageSize();
        PageHelper.startPage(currentPage,pageSize);
        Page<Sprots> page=sprotsDao.findpageRepos(queryPageBean.getQueryString());
        return new PageResult(page.getTotal(),page.getResult());
    }
}
